var e = require;
var t = module;
var o = exports;
var ii, nn = this && this.__extends || (ii = function (t, e) {
    return (ii = Object.setPrototypeOf || {
        __proto__: []
    }
        instanceof Array &&
        function (t, e) {
            t.__proto__ = e
        } ||
        function (t, e) {
            for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o])
        })(t, e)
},
    function (t, e) {
        function o() {
            this.constructor = t
        }
        ii(t, e),
            t.prototype = null === e ? Object.create(e) : (o.prototype = e.prototype, new o)
    }
),
    rr = this && this.__awaiter ||
        function (t, e, o, i) {
            return new (o || (o = Promise))(function (n, a) {
                function r(t) {
                    try {
                        l(i.next(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function s(t) {
                    try {
                        l(i.
                            throw(t))
                    } catch (e) {
                        a(e)
                    }
                }
                function l(t) {
                    var e;
                    t.done ? n(t.value) : (e = t.value, e instanceof o ? e : new o(function (t) {
                        t(e)
                    })).then(r, s)
                }
                l((i = i.apply(t, e || [])).next())
            })
        };
var oo = (this && this.__decorate) ||
    function (e, t, a, n) {
        var i,
            o = arguments.length,
            s = o < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, a)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) s = Reflect.decorate(e, t, a, n);
        else
            for (var r = e.length - 1; r >= 0; r--)
                (i = e[r]) && (s = (o < 3 ? i(s) : o > 3 ? i(t, a, s) : i(t, a)) || s);
        return o > 3 && s && Object.defineProperty(t, a, s), s;
    };
Object.defineProperty(o, "__esModule", { value: !0 });
var a = e("GlobalParams"),
    n = e("AssetsManager"),
    i = e("ModuleUI"),
    r = e("CommonHelper"),
    s = e("nameCfg"),
    l = e("sdkConfig"),
    _ = e("AD"),
    c = cc._decorator,
    d = c.ccclass,
    h = c.property,
    u = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.player_name_label = null),
                (t.player_head_sprite = null),
                (t.player_level_label = null),
                (t.game_mode = null),
                (t.mode_index = 0),
                t
            );
        }
        return (
            nn(t, e),
            (t.prototype.initView = function () {
                e.prototype.initView.call(this), (this.mode_index = r.default.getRandomInt(0, 2)), this.showMatchInfo();
            }),
            (t.prototype.OnClick = function (t) {
                switch ((e.prototype.OnClick.call(this, t), t.node.name)) {
                    case "consent_btn":
                        (a.GlobalParams.ChangeGameMode = this.mode_index),
                            (a.GlobalParams.MathcTimeInfo.open = !1),
                            (a.GlobalParams.MathcTimeInfo.time = 180),
                            this.uiManager.showPopup("MatchViewUI"),
                            this.closeThisPopup();
                        break;
                    case "refuse_btn":
                    case "back_btn":
                        (a.GlobalParams.MathcTimeInfo.time = 180),
                            (a.GlobalParams.MathcTimeInfo.open = !0),
                            this.closeThisPopup();
                }
            }),
            (t.prototype.showMatchInfo = function () {
                a.GlobalParams.gameShock.value && _.default.getInstance().vibrateShort(),
                    (this.game_mode.spriteFrame = n.default
                        .getInstance()
                        .getModeInfoFrame("mode_type_" + this.mode_index)),
                    (a.GlobalParams.MathcTimeInfo.open = !1);
                var e = a.GlobalParams.PlayerInfo.value,
                    t = "";
                do {
                    t =
                        l.default.platform != l.EPlatform.NET_4399
                            ? s.default.nameList[r.default.getRandomInt(0, s.default.nameList.length - 1)]
                            : "4399玩家" + r.default.getRandomInt(1e3, 9999);
                } while (t == e.name);
                var o = r.default.getRandomInt(1, 15);
                (a.GlobalParams.MathcTimeInfo.name = t),
                    (a.GlobalParams.MathcTimeInfo.head = o),
                    (this.player_name_label.string = t),
                    (this.player_head_sprite.spriteFrame = n.default.getInstance().getHeroHeadFrame("hero_" + o));
                var i = e.level + r.default.getRandomInt(-2, 2);
                this.player_level_label.string = "Lv." + (i < 1 ? 1 : i);
            }),
            oo([h(cc.Label)], t.prototype, "player_name_label", void 0),
            oo([h(cc.Sprite)], t.prototype, "player_head_sprite", void 0),
            oo([h(cc.Label)], t.prototype, "player_level_label", void 0),
            oo([h(cc.Sprite)], t.prototype, "game_mode", void 0),
            oo([d], t)
        );
    })(i.default);
o.default = u;
